home *** CD-ROM | disk | FTP | other *** search
/ Nebula 2 / Nebula Two.iso / SourceCode / NMK / Recorders / SliderCellCover.m < prev    next >
Text File  |  1995-06-12  |  2KB  |  79 lines

  1. /***** SliderCellCover.m -- SliderCellCover object implementation
  2.     NeXTstep Measurement Kit
  3.     by Alex Meyer <ameyer@phoenix.Princeton.EDU>
  4.     for computer science senior thesis
  5.     18 April 1992 -- created
  6.     20 April 1992 -- role of RSliderCell absorbed
  7.     23 April 1992 -- this file changed from RSlider.m to RSliderCell.m
  8.         utilizes late connect approach & LINKERNAME
  9.     24 April 1992 -- renamed from RSliderCell.m to SliderCellCover.m
  10.         uses object name link to RSliderVars
  11. *****/
  12.  
  13. #import <sys/time.h>
  14. #import <appkit/Application.h>
  15. #import "RSliderVars.h"
  16. #import "SliderCellCover.h"
  17.  
  18. #define VARSNAME ("SliderVars")
  19.  
  20. #define MICRO (1000000.0)
  21. #define DOUBLETIME(stv) ((double) (((unsigned long) (stv).tv_sec) \
  22.     + (((unsigned long) (stv).tv_usec) / MICRO)))
  23.  
  24. @implementation SliderCellCover
  25.  
  26. - makeVarsRect:(const NXRect *)rect
  27. {
  28.     id vars;
  29.  
  30.     if (!(rect))
  31.         rect = &trackRect;
  32.     vars = [RSliderVars alloc];
  33.     [vars initString:contents
  34.         tag:tag
  35.         rect:rect];
  36.     NXNameObject(VARSNAME,vars,self);
  37.     return (vars);
  38. }
  39.  
  40.  
  41. - (BOOL)trackMouse:(NXEvent *)theEvent
  42.     inRect:(const NXRect *)cellFrame
  43.     ofView:controlView
  44. {
  45.     id vars;
  46.     BOOL res;
  47.     int index;
  48.     double time0,time1;
  49.     struct timeval start,finish;
  50.     struct timezone zone;
  51.  
  52.     gettimeofday(&start,&zone);
  53.     res = [super trackMouse:theEvent
  54.         inRect:cellFrame
  55.         ofView:controlView];
  56.     gettimeofday(&finish,&zone);
  57.     time0 = DOUBLETIME(start);
  58.     time1 = DOUBLETIME(finish);
  59.     if (!(contents))    /* propagate name of Slider */
  60.         contents = NXGetObjectName(controlView);
  61.     vars = NXGetNamedObject(VARSNAME,self);
  62.     if (!(vars))
  63.         vars = [self makeVarsRect:cellFrame];
  64.     [vars incHits];
  65.     [vars timeFrom:time0
  66.         to:time1];
  67.     index = (value - minValue) / (maxValue - minValue) * SLIDERHIST;
  68.     if (index >= SLIDERHIST)
  69.         index = SLIDERHIST - 1;
  70.     [vars incHist:index];
  71.     return (res);
  72. }
  73.  
  74. @end
  75.  
  76. #undef DOUBLETIME
  77. #undef MICRO
  78. #undef VARSNAME
  79.